package com.oa.hyperion.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.oa.hyperion.entity.assets.AssetsDetail;
import com.oa.hyperion.entity.assets.AssetsRepair;
import com.oa.hyperion.repository.assets.AssetsRepairMapper;
import com.oa.hyperion.service.AssetsRepairService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AssetsRepairServiceImpl implements AssetsRepairService {
    @Autowired
    private AssetsRepairMapper assetsRepairMapper;

    @Override
    public void insert(AssetsRepair assetsRepair) {
        assetsRepairMapper.insert(assetsRepair);
    }

    /**
     * 维修完成后，更新维修结果
     * author yuanchongwei
     * date 2022-1-18
     * @param id 主键
     * @param result 维修结果：0:修复成功，1:修复中，2:失败（报废）
     */
    @Override
    public boolean update(int id, String result) {
        return assetsRepairMapper.update(id,result);
    }

    @Override
    public List<AssetsRepair> getAllRepairInfo() {
        return assetsRepairMapper.getAllRepairInfo();
    }

    @Override
    public List<AssetsRepair> getAssetsRepairByAssetId(int asset_id) {
        return assetsRepairMapper.getAssetsRepairByAssetId(asset_id);
    }

    @Override
    public List<AssetsRepair> getAssetsRepairByResult(int result) {
        return assetsRepairMapper.getAssetsRepairByResult(result);
    }

    @Override
    public String getAssetsRepairByResultLatest(int assetId) {
        return assetsRepairMapper.getAssetsRepairByResultLatest(assetId);
    }

    @Override
    public List<AssetsRepair> getAssetsRepairByApplyer(String applyer) {
        return assetsRepairMapper.getAssetsRepairByApplyer(applyer);
    }

    @Override
    public List<AssetsRepair> getAssetsRepairByResponser(int responser) {
        return assetsRepairMapper.getAssetsRepairByResponser(responser);
    }

    @Override
    public PageInfo<AssetsRepair> getByCondition(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<AssetsRepair> assetsRepairs = assetsRepairMapper.getAllRepairInfo();
        return new PageInfo<>(assetsRepairs);
    }

}
